#include <iostream>
#include <string>
#include <stack>
#include <unordered_map>

bool s(const std::string& r) {
    std::stack<char> a;
    std::unordered_map<char, char> z = {{')', '('}, {']', '['}, {'}', '{'}, {'>', '<'}};

    for (char b : r) {
        if (z.find(b) == z.end()) { // if b is an opening bracket
            a.push(b);
        } else { // if b is a closing bracket
            if (a.empty()) {
                return false;
            }
            if (a.top() == z[b]) {
                a.pop();
            } else {
                return false;
            }
        }
    }
    return a.empty();
}

int main() {
    std::string r;
    std::cout << "Введите порядок скобок";
    std::cin >> r;
    bool d = s(r);
    std::cout << (d ? "True" : "False") << std::endl;
    return 0;
}

